package com.heima.media.controller;

import com.heima.media.service.WmNewsService;
import com.heima.model.common.dtos.PageRequestDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.dto.WmNewsDto;
import com.heima.model.wemedia.pojos.dto.WmNewsQueryDto;
import com.heima.model.wemedia.pojos.pojos.WmNews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author mgw
 * @create 2021/9/30 16:44
 */
@RestController
@RequestMapping("/api/v1/wmNews")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;
    @PostMapping("/search")
    public ResponseResult searchNews(@RequestBody PageRequestDto<WmNewsQueryDto> requestDto){
       return wmNewsService.searchNews(requestDto);
    }
    @PostMapping(value = "/submit")
    public ResponseResult submit(@RequestBody WmNewsDto dto){
        return wmNewsService.submit(dto);
    }
    @PutMapping(value = "/{id}/{updown}")
    public ResponseResult upOrDown(@PathVariable(value = "id")Integer id
            ,@PathVariable(value = "updown")Integer updown){
        wmNewsService.upOrDown(id,updown);
        return ResponseResult.okResult(null);
    }

}
